<template>
	<view>
		<uni-nav-bar left-icon="left"  :statusBar="true" titleSize="30px" leftText="返回" right-text="修改" title="物流详情" @clickRight="toEditInfo"  @clickLeft="back"  :fixed="true" backgroundColor="#3286ed" color="#fff"/>
		<!-- 列表 -->
		<view v-if="Object.values(item).length > 0">
			<view class="box">
				<view>订单编号：{{item.orderNo}}</view>
				<view>项目名称：{{item.projectName}}</view>
				<view>仓库：{{item.warehouseName}}</view>
			</view>
			<view style="background-color: #fff;margin-top: 5px;">
				<u-cell>
					<template #title>
						<view style="font-size: 12px;">基本信息</view>
					</template>
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">订单编号</text>
						<text class="u-cell-text">{{item.orderNo}}</text>
					</view>
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">业务员</text>
						<text class="u-cell-text">{{item.salesmanName}}</text>
					</view>
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">出库单编号</text>
						<text class="u-cell-text">{{item.outboundNo}}</text>
					</view>
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">入库申请编号</text>
						<text class="u-cell-text">{{item.returnApplyNo}}</text>
					</view>
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">目的地</text>
						<text class="u-cell-text">{{item.projectAddress}}</text>
					</view>
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">项目名称</text>
						<text class="u-cell-text">{{item.projectName}}</text>
					</view>
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">物流费用</text>
						<text class="u-cell-text">{{item.logisticsExpenses}}</text>
					</view>
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">运输方式</text>
						<text class="u-cell-text">{{item.shippingType}}</text>
					</view>
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">司机名称</text>
						<text class="u-cell-text">{{item.driverName}}</text>
					</view>
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">司机电话</text>
						<text class="u-cell-text">{{item.driverTel}}</text>
					</view>
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">司机车辆信息</text>
						<text class="u-cell-text">{{item.vehicleInformation}}</text>
					</view>
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">识别信息</text>
						<text class="u-cell-text">{{item.serialNumber}}</text>
					</view>  
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">仓库</text>
						<text class="u-cell-text">{{item.warehouseName}}</text>
					</view>  
				</u-cell>
				<u-cell>
					<view  slot="title" class="u-slot-title">
						<text class="u-cell-text">到货日期</text>
						<text class="u-cell-text">{{item.arrivalDate}}</text>
					</view>  
				</u-cell>
			</view>
			 
			<view  style="padding-right: 5xp;">
				<uni-table border stripe emptyText="暂无更多数据" >
					<!-- 表头行 -->
					<uni-tr>
						<uni-th align="center" width="70px">产品名称</uni-th>
						<uni-th align="center" width="60px">型号</uni-th>
						<uni-th align="center" width="50px">数量</uni-th>
						 
					</uni-tr>
					<!-- 表格数据行 -->
					<uni-tr v-for="(item,index) in item.logisticsProductList" :key="index">
						<uni-td align="center">{{item.productName}}</uni-td>
						<uni-td align="center">{{item.model}}</uni-td>
						<uni-td align="center">
							<template slot-scope="scope">
								<input v-model="item.quantity" type="text">
							</template>
						</uni-td>
						 
					</uni-tr>
				</uni-table>
			</view>
		</view>
		<view v-if="Object.values(item).length == 0" class="BGC"></view>
	
	</view>
</template>

<script>
	import {getLogisticsInfoApi} from "@/api/logistics.js"
	import {getDicts} from '@/api/dictionary/index.js'
	export default {
		data(){
			return{
				 item:{},
				id:'',
				LogisticsOptions:[]
			}
		},
		onLoad(val){
			 this.id=val.id
			console.log(val);
			this.getLogisticsList()
				this.initData()
		},
		created() {
			this.initData()
		},
		methods:{
			getValue(arr, item) {
			      for (let i = 0; i < arr.length; i++) {
			        if (item === arr[i].dictValue) {
			          return arr[i].dictLabel
			        }
			      }
			    },
			async getLogisticsList(){
			  let res=await getDicts('biz_shipping_type')
			  this.LogisticsOptions=res.data
			},
			async initData(){
				let res=await getLogisticsInfoApi(this.id)
				 
				this.item=res.data
				this.item.shippingType=this.getValue(this.LogisticsOptions,this.item.shippingType)
			},
			toEditInfo(){
				
				uni.navigateTo({
					url:'/pages/logistic/editlogistic/editlogistic?item='+encodeURIComponent(JSON.stringify(this.item))
				})
			},
			back(){
				uni.redirectTo({
					url:'/pages/logistics/index'
				})
			},
			
		}
	}
</script>

<style lang="scss">
	.u-slot-title{
		.u-cell-text{
			margin-right: 15px;
		}
	}
	.bgc{
		width: 10px;
		height: 10px;
		line-height: 10px;
		display: inline-block;
		text-align: center;
		background-color: #fd9540;
	}
	.box{
		padding: 10px;
		font-size: 14px;
		background-color: #fff;
	}
	.BGC{
		width: 100%;
		min-height: 400px;
		background-image: url('@/static/images/bgc.png');
		background-size:100% 200px;
		background-repeat: no-repeat;
	}
</style>